/* 笔记 */
var express = require("express");
var router = express.Router();

const noteController = require("../controller/note");

// 获取笔记列表
router.get("/getNoteList", (req, res) => {
  const labelId = req.query.labelId;
  noteController
    .getNoteList(labelId)
    .then((data) => {
      res.send(JSON.stringify(data));
    })
    .catch((err) => {
      res.send(err);
    });
});

// 新增笔记
router.post("/addNote", (req, res) => {
  const data = req.body;
  noteController.addNote(data).then((result, err) => {
    if (err) {
      res.send(err);
      return;
    }
    res.send(JSON.stringify(result));
  });
});

module.exports = router;
